package com.example.demo.dao;


import com.example.demo.pojo.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface UserMapper {


    @Select("select password from user where reader_id = #{reader_id}")
    String selUserByReaderid(int reader_id);

    @Update("update user set password = #{password} where reader_id = #{reader_id}")
    void updateUserPasswordByReaderid(int reader_id,String password);

    @Insert("insert into user(name,stunum,password,phone,user_state,state) values(#{name},#{stunum},#{password},#{phone},#{user_state},#{state})")
    int insertUser(User user);

    @Update("update user set state = #{state} where reader_id = #{reader_id}")
    void updateUserStateById(int reader_id,int state);


    void updateUserByReaderId(User user);

    @Select("select * from user where stunum = #{stunum}")
    List<User> selUserByStuNum(String stunum);

    @Select("select * from user where reader_id = #{reader_id}")
    User findUserByReaderId(int reader_id);

    //0-超管,1-管理员,2-读者
    @Select("select * from user where user_state = #{user_state}")
    List<User> findAllUser(int user_state);


    List<User> findAllUserByConditions(User user);


    int findAllUserCountByConditions(User user);

    @Select("select count(*) from user where user_state = #{user_state}")
    int findAllUserCount(int user_state);

}
